package utils

import (
	"errors"
	"github.com/gin-gonic/gin"
	"strconv"
)

func GetUseridFromCtx(c *gin.Context) (userid int64, err error) {
	useridStr, ok := c.Get("userid")
	if !ok {
		err = errors.New("userid not found")
		return
	}
	userid, err = strconv.ParseInt(useridStr.(string), 10, 64)
	if err != nil {
		return
	}
	return
}
